//
//  UIButton+SDBlock.m
//  skinDetection
//
//  Created by  liangzhun on 2018/10/29.
//  Copyright © 2018年  liangzhun. All rights reserved.
//

#import "UIButton+SDBlock.h"

@implementation UIButton (SDBlock)
static char overviewKey;

- (void)handleControlEvent:(UIControlEvents)controlEvent withBlock:(ActionBlock)action {
    objc_setAssociatedObject(self, &overviewKey, action, OBJC_ASSOCIATION_COPY_NONATOMIC);
    [self addTarget:self action:@selector(callActionBlock:) forControlEvents:controlEvent];
}

- (void)callActionBlock:(id)sender {
    ActionBlock block = (ActionBlock)objc_getAssociatedObject(self, &overviewKey);
    if (block) {
        block();
    }
}
- (void)setHighlighted:(BOOL)highlighted
{
    
}
@end
